﻿
 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		
		<title>jb-aptech毕业设计项目</TITLE>
<meta name="renderer" content="ie-comp">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="../../css/style.css" rel="stylesheet" type="text/css">
		<script src="../../script/common.js"></script>
		<script src="../../script/validate.js"></script>
		<link rel="stylesheet" type="text/css" href="ExtJS/resources/css/ext-all.css">
<script type="text/javascript" src="ExtJS/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ExtJS/ext-all.js"></script>
        <link rel="stylesheet" href="/css/bootstrap.min.css" type="text/css"></link>
        <script type="text/javascript" src="/js/jquery.min.js"></script>
        <script type="text/javascript" src="/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="/js/vue.js"></script>
	</head>
	<script type="text/javascript">
		
		function mySearch(){
			var arrName=new Array();
				arrName[0]="roleName";
				checkWay(arrName);
				document.sysRoleForm.submit();
		}
	
	</script>
	<body>
		<div class="page_title">
			权限管理 > 用户管理 > 系统角色管理
		</div>
        <div id="list">
		<form name="sysRoleForm" method="post" action="/CRM/sysRole.do">
			<input type="hidden" name="method" value="roleForward">
			<div class="button_bar">
				<button class="common_button" onclick="help();">
					帮助
				</button>
				<button class="common_button"
					@click="build()" type="button">
					新建
				</button>
				<button class="common_button" @click="query(1)" type="button">
					查询
				</button>
			</div>
			<table class="query_form_table">
				<tr>
					<th>
						角色名
					</th>
					<td>
						<input type="text" v-model="sysRole.role_name" size="20" id="roleName">
					</td>
					<th>角色描述</th>
					<td>
						<input type="text" v-model="sysRole.role_desc" size="20">
					</td>
					<th>
						是否禁用
					</th>
					<td>
						<select v-model="sysRole.role_flag"><option value="">全部</option>
							<option value="1">正常</option>
							<option value="0">禁用</option></select>
					</td>
				</tr>
			</table>
			<br />
			<table class="data_list_table">
				<tr>
					<th>
						编号
					</th>
					<th>
						角色名
					</th>
					<th>
						角色描述
					</th>
					<th>
						状态
					</th>
					<th>
						操作
					</th>
				</tr>
				
					<tr v-for="r,i in sysRoles">
						<td class="list_data_text">
							{{i+1}}
						</td>
						<td class="list_data_text">
							{{r.role_name}}
						</td>
						<td>
							{{r.role_desc}}
						</td>
						<td class="list_data_text">
							
	   							{{r.role_flag==1?'正常':'禁用'}}
	   						
							
						</td>
						<td class="list_data_op">
							<img @click="edit(r)" title="编辑" src="images/bt_edit.gif" class="op_button"/>
                            <img @click="setMight(r)"
                                 title="分配权限" src="/html/images/bt_linkman.gif" class="op_button" />

							<img @click="find(r)"
								title="查看" src="images/bt_deal.gif" class="op_button" />
						
							<img
								@click="mydel(r.role_id)"
								title="删除" src="images/bt_del.gif" class="op_button" />
						
						</td>
					</tr>
                <tr>
                    <th colspan="100" class="pager">
                        <div class="pager">
                            共{{pageInfo.total}}条记录
                            每页<input style="width: 30px;text-align: center" v-model="pageInfo.pageSize" />条
                            第<input v-model="pageInfo.pageNum" style="width: 30px;text-align: center"/>页/共{{pageInfo.pages}}页
                            <a @click="query(1)" href="javascript:;">第一页</a>
                            <a @click="query(pageInfo.pageNum-1)" href="javascript:;">上一页</a>
                            <a @click="query(pageInfo.pageNum+1)" href="javascript:;">下一页</a>
                            <a @click="query(pageInfo.pages)" href="javascript:;">最后一页</a>
                            转到<input v-model="pageInfo.pageNum" style="width: 30px;text-align: center"  />页
                            <button  @click="query(pageInfo.pageNum)"  type="button">GO</button>
                        </div>
                    </th>
                </tr>
			</table>
		</form>
        </div>
        <script>
            var roles=new Vue({
                el:"#list",
                data:{
                    sysRoles:[],
                    pageInfo:'',
                    sysRole:{
                        role_name:'',
                        role_desc:'',
                        role_flag:'',
                        pageNum:''
                    }
                },
                methods:{
                    setMight(r){
                        sessionStorage.setItem("r",JSON.stringify(r));
                        location="roleRight.html";
                    },
                    query(num){
                        this.pageInfo.pageNum=num;
                        if(num<1){
                            this.pageInfo.pageNum=1;
                        }
                        if(num>this.pageInfo.pages)
                            this.pageInfo.pageNum=this.pageInfo.pages;

                        this.sysRole.pageNum=this.pageInfo.pageNum;
                        $.getJSON("/SysRole/queryPage",this.sysRole,function(json){
                            roles.sysRoles=json.data.pageInfo.list;
                            roles.pageInfo=json.data.pageInfo;
                        });
                    },
                    edit(role){
                        sessionStorage.setItem("role",JSON.stringify(role));
                        location="/html/~right/role/edit.html";
                    },
                    find(role){
                        sessionStorage.setItem("role",JSON.stringify(role));
                        location="/html/~right/role/detail.html";
                    },
                    mydel(roleId){
                        $.getJSON("/deleteRole/"+roleId,function(json){
                            if(json.code==200){
                                alert("删除成功！");
                            }else{
                                alert("删除失败！");
                            }
                        })
                    },
                    build(){
                        location="/html/~right/role/add.html";
                    }
                },
                created(){
                    $.getJSON("/SysRole/queryPage",{},function(json){
                        roles.sysRoles=json.data.pageInfo.list;
                        roles.pageInfo=json.data.pageInfo;
                    });
                }
            });
        </script>
	</body>
</html>

